package com.zl.customer.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 退出
 * @author suke
 * @create 2021-07-08 11:04
 */
@WebServlet(name = "LogoutServlet",urlPatterns = "/logout.action")
public class LogoutServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.设置编码
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");


        //2 业务代码
        //让session失效
        request.getSession().invalidate();

        //3. 页面跳转
        response.sendRedirect(request.getContextPath()+"/login.jsp");
    }
}
